package com.sk.bilibili.model.fragment.channel;

import com.sk.api.annotations.Autowired;
import com.sk.bilibili.mapper.BannerMapper;
import com.sk.bilibili.mapper.VideoSetMapper;
import com.sk.bilibili.model.BaseRefreshModel;
import com.sk.bilibili.utils.RequestUtils;
import com.sk.bilibili.view.fragment.channel.FullVideoSetFragment;

public class VideoSetModel extends BaseRefreshModel<FullVideoSetFragment> {

    @Autowired
    VideoSetMapper videoSetMapper;
    @Autowired
    BannerMapper bannerMapper;
    private int page=1;
    private int size=10;

    public void loadMore(Integer typeId) {
        RequestUtils.process(videoSetMapper.page(page, size, typeId), videoSetPage -> {
            view.loadMoreSuccess(videoSetPage.getRecords());
            page++;
        });
    }

    public void refresh(Integer typeId) {
        page=1;
        RequestUtils.process(videoSetMapper.page(page, size, typeId), videoSetPage -> {
            view.refreshSuccess(videoSetPage.getRecords());
            page++;
        });
    }

    public void loadBanner(Integer typeId) {
        RequestUtils.process(bannerMapper.getBanner(typeId), banners -> view.loadBannerSuccess(banners));
    }

}